<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>认证中心</title>
    <link rel="stylesheet" href="./layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="./systemStatic/style/login.css" media="all" type="text/css"/>
</head>
<body layadmin-themealias="default" class="layui-layout-body" style="">
<div class="layadmin-user-login layadmin-user-display-show" style="margin-left: 100px">
    <div class="layadmin-user-header" style="font-size: 24px; ">
        <a href="${ctx}/homePage" style="margin-left: 0px">首页</a>
        <a href="" >概况</a>
        <a href="" >产品</a>
        <a href="" >关于</a>
    </div>

    <h1>你好!</h1>
    <p class="layadmin-user-p welcomeToUse">欢迎来到我们的世界!</p>
    <!--<div class="layadmin-user-login-main">-->
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form" style="padding-left: 0">
                <input type="hidden" name="serviceUrl" value="${serviceUrl}">
                <input type="hidden" name="tips" value="${msg}">
                <input type="hidden" id="userId" name="userId" value="">

            <div class="layadmin-user-login-mess" style="width: 380px">
            <input type="text" id="account" name="account" class="layui-input" lay-verify="required"
                   placeholder="用户名" autocomplete="off" value=""/>
            <div class="kit-login-col"></div>
            <input type="password" value="" id="password" name="password" lay-verify="required" placeholder="密码"
                   autocomplete="off" class="layui-input" style="width: 380px"/>
            <div class="kit-login-col"></div>
            </div>

                <div class="layui-form-item validCode" <#if !useValidCode >style="display:none"</#if>>
                    <label class="layadmin-user-login-icon layui-icon layui-icon-vercode"></label>
                    <input type="input" style="width: 220px;float: left;margin: 20px 20px 0 0;" id="validCode" name="validCode"
                           lay-verify="<#if useValidCode >required</#if>" placeholder="验证码" autocomplete="off" class="layui-input"/>
                    <img src="${ctx}/valid/getCode" style="margin-top:24px;" onclick="getValidCode(this);"/>
                    <div class="kit-login-col"></div>
                </div>
                <input type="hidden" id="useValidCode" name="useValidCode" value="false" />
                <div class="kit-login-row"><span style="color: firebrick">${msg}</span>
                    <!--<div class="kit-login-col">-->
                    <!--<input type="checkbox" name="rememberMe" value="true" title="记住密码" lay-skin="primary">-->
                    <!--<a class="forgot" href="javascript:;" style=" text-decoration: none; font-size: 13px;" id="forgot">忘记密码？</a>-->
                    <!--</div>-->
                </div>
                <div class="kit-login-row">
                    <button class="layui-btn layui-btn-normal" lay-submit="submit" lay-filter="login_hash" id="login_hash">马上登录</button>
                </div>

                <div class="layadmin-user-forgetPass">
                    <a href="" id="forget" style="margin-right: 270px">忘记密码？</a>
                    <a href="" id="logup">注册</a>
                </div>

        </div>
    <!--</div>-->

</div>

<div style="padding:20px;" id="UserNameKeywords" style="display: none;">
    <form class="layui-form" action="">
        <div >
            <div >
                <ul id="listTest"></ul>
            </div>
        </div>
        <div class="layui-form-item" style="display:none">
            <label class="layui-form-label">用户ID:</label>
            <div class="layui-input-block">
                <input type="text" name="title" required  lay-verify="required" autocomplete="off" class="layui-input" id="test1">
            </div>
        </div>
        <div class="layui-form-item" style="display:none">
            <label class="layui-form-label">用户权重:</label>
            <div class="layui-input-block">
                <input type="text" name="title" required  lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
    </form>
</div>

<script src="./layui/layui.js"></script>

<script>
    function getValidCode(obj) {
        obj.src = "${ctx}/valid/getCode?" + Math.random();
    }
    layui.use(['form'], function(){
        var $ = layui.$
            ,setter = layui.setter
            ,admin = layui.admin
            ,form = layui.form
            ,layer = layui.layer
        $(function() {
            if (window != top) {
                top.layer.alert("登录超时，请重新登录！", {
                    skin: 'layui-layer-lan'
                    ,closeBtn: 0
                    ,shift: 2
                },function () {
                    top.location.href = location.href;
                });
        }
        });
        form.render();
        //提交
        form.on('submit(login_hash)', function(obj){
            ajaxSubmit(obj.field)
        });
        $('body').keydown(function () {
            if(event.keyCode == '13'){
                $("#login_hash").click();
                    // var data={};
                    // data.password=$("#password").val();
                    // data.account=$("#account").val();
                    // data.validCode=$("#validCode").val();
                    // ajaxSubmit(data);
            }
        });

        /* 获取弹出层事件 */
        function UserNameKeywords(keywords){
            layer.open({
                type: 1,
                title : '当前用户信息',
                area: ['450px', '400px'],
                offset : '16px',
                shadeClose : true, // 点击遮罩关闭
                btn : ['取消'],
                content:$('#UserNameKeywords')
            });
            $("#listTest").text("");
            for(var i=0;i<keywords.length;i++){
                var orgPathName = keywords[i].orgPathName;
                orgPathName = orgPathName.replace("租户管理/", "");
                $("#listTest").append("<li onclick='selectedUser(\" "+keywords[i].userId+" \")' style='margin-bottom: 11px;font-size: 17px;margin-bottom: 21px;padding-bottom: 3px;border-bottom: 1px solid #E3E0E0;'>"+orgPathName+"/"+keywords[i].fullName+"</li>")
            }
        }

        selectedUser = function(userId){
            document.getElementById("userId").value = userId;
            document.getElementById("login_hash").click();
        }

        function ajaxSubmit(data) {
            $.ajax({
                url: "${ctx}/loginExecute"
                ,data: data
                ,type:'post'
                ,dataType:'json'
                ,success:function(res){
                    if(res.code == 0){
                        //登入成功的提示与跳转
                        window.location.href = "${ctx}/index"
                    }else if(res.code == 2){
                        //选择用户登录
                        UserNameKeywords(res.data);
                    }
                    else{
                        if(res.data?res.data.useValidCode:false){
                            $(".validCode").attr("style", "display:block");
                            $(".validCode input").attr("lay-verify","required");
                            $("#useValidCode").val(true)
                        }
                        $(".validCode img").click();
                        layer.msg(res.msg);
                    }
                }
            });
        }
    });
</script>
</body>

</html>
<style>
    .layui-layout-body{
        background-image: url('./systemStatic/login/login.jpg');
        height: 969px;
        width: 100%;
    }
    .layadmin-user-login .layadmin-user-header a{
        margin: 30px 40px;
    }

    .layadmin-user-display-show h1{
        margin-top: 40px;
    }
    .welcomeToUse{
        margin: 30px 0px 80px 0px;
        font-size: 18px;
    }
    .layadmin-user-login-mess #account{
        width: 380px;
        height: 42px;
        margin-bottom: 26px;
    }
    .kit-login-row #login_hash{
        width: 380px;
        margin-top: 40px;
        margin-bottom: 80px;
    }
    .layadmin-user-forgetPass{
        color: #9d9d9e;
        font-size: 14px;
        text-decoration: none;
    }
</style>
